/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.krossk.jspControllers;

import br.com.krossk.model.Usuario;
import java.io.IOException;
import javax.servlet.http.HttpSession;

/**
 *
 * @author Henrique
 */
public class AccessValidation {
    public static boolean userValidation(HttpSession session, int idPrivilegio) {
        try{
            Usuario u = (Usuario)session.getAttribute("usuario");
            if(u==null||u.getPrivilegio().getIdPrivilegio()>idPrivilegio)
                return false;
            return true;
        }catch(NullPointerException npe){
            return false;
        }
    }
    public static boolean userValidation(HttpSession session) {
         try{
            Usuario u = (Usuario)session.getAttribute("usuario");
            if(u==null)
                return false;
            return true;
        }catch(NullPointerException npe){
            return false;
        }
    }
}
